package com.mollytask.base;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.mollytask.R;
import com.mollytask.bean.DataFill;
import com.mollytask.bean.Institution;

import butterknife.BindView;
import butterknife.ButterKnife;

public abstract class BaseDetailActivity extends AppCompatActivity {


    protected DataFill mDataFill;

    protected Institution mInstitution;

    protected EditText et_code, et_name, et_type, et_adress, et_post_code, et_email, et_phone, et_fuzeren, et_usenum, et_hotarea, et_coldarea, et_stati_name, et_stati_phone;

    private LinearLayout mBackLl;

    @BindView(R.id.et_waterPrice)
    protected EditText et_waterPrice;
    @BindView(R.id.et_coalAmount)
    protected EditText et_coalAmount;
    @BindView(R.id.et_coalPrice)
    protected EditText et_coalPrice;
    @BindView(R.id.et_elecAmount)
    protected EditText et_elecAmount;
    @BindView(R.id.et_elecPrice)
    protected EditText et_elecPrice;
    @BindView(R.id.et_gasAmount)
    protected EditText et_gasAmount;
    @BindView(R.id.et_gasoglineAmount)
    protected EditText et_gasoglineAmount;
    @BindView(R.id.et_gasolinePrice)
    protected EditText et_gasolinePrice;
    @BindView(R.id.et_gasPrice)
    protected EditText et_gasPrice;
    @BindView(R.id.et_waterAmount)
    protected EditText et_waterAmount;

    @BindView(R.id.btn_resubmit)
    protected Button mReSubmit;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(setLayout());

        ButterKnife.bind(this);
        mDataFill = (DataFill) getIntent().getSerializableExtra("dataFillResult");
        mInstitution = (Institution) getIntent().getSerializableExtra("institution");
        receiveData();
        initView();
        initData();
        init();
    }

    public abstract int setLayout();

    public abstract void receiveData();

    public abstract void init();

    private void initView() {
        mBackLl = (LinearLayout) findViewById(R.id.ll_back);
        et_code = (EditText) findViewById(R.id.et_code);
        et_name = (EditText) findViewById(R.id.et_name);
        et_type = (EditText) findViewById(R.id.et_type);
        et_adress = (EditText) findViewById(R.id.et_adress);
        et_post_code = (EditText) findViewById(R.id.et_post_code);
        et_email = (EditText) findViewById(R.id.et_email);
        et_phone = (EditText) findViewById(R.id.et_phone);
        et_fuzeren = (EditText) findViewById(R.id.et_fuzeren);
        et_usenum = (EditText) findViewById(R.id.et_usenum);
        et_hotarea = (EditText) findViewById(R.id.et_hotarea);
        et_coldarea = (EditText) findViewById(R.id.et_coldarea);
        et_stati_name = (EditText) findViewById(R.id.et_stati_name);
        et_stati_phone = (EditText) findViewById(R.id.et_stati_phone);


        mBackLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initData() {

        et_code.setText(mInstitution.getmInCode());
        et_name.setText(mInstitution.getmInName());
        et_type.setText(mInstitution.getmInType());
        et_adress.setText(mInstitution.getmInAddress());
        et_post_code.setText(mInstitution.getmInPostCode());
        et_email.setText(mInstitution.getmInEmail());
        et_phone.setText(mInstitution.getmInPaxPhone());
        et_fuzeren.setText(mInstitution.getmInDirector());

        et_waterPrice.setText(mDataFill.getWaterPrice());
        et_waterAmount.setText(mDataFill.getWaterAmount());
        et_coalAmount.setText(mDataFill.getCoalAmount());
        et_coalPrice.setText(mDataFill.getCoalPrice());
        et_elecPrice.setText(mDataFill.getElecPrice());
        et_elecAmount.setText(mDataFill.getElecAmount());
        et_gasPrice.setText(mDataFill.getGasPrice());
        et_gasAmount.setText(mDataFill.getGasAmount());
        et_gasolinePrice.setText(mDataFill.getGasolinePrice());
        et_gasoglineAmount.setText(mDataFill.getGasoglineAmount());


        et_usenum.setText(mDataFill.getmConsumerNo());
        et_coldarea.setText(mDataFill.getmCoolArea());
        et_hotarea.setText(mDataFill.getmHeatArea());
        et_stati_name.setText(mDataFill.getmStatisticianName());
        et_stati_phone.setText(mDataFill.getmStatisticianTel());

    }
}
